package com.kaifamiao.decimal;

import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * 所有的浮点数都遵守 IEEE 754 规范
 */
public class FloatPointCalculation {

    public static void main(String[] args) {
        double x = 0.1;
        double y = 0.2;
        double t = x + y;
        System.out.println( t );

        System.out.println( "- ".repeat( 20 ) );

        BigDecimal first = BigDecimal.valueOf( 1, 1 );
        System.out.println( first );

        BigDecimal second = BigDecimal.valueOf( 2, 1 );
        System.out.println( second );
        // 调用 first 的 add 实现 求 first 和 second 之和
        BigDecimal result = first.add( second );
        System.out.println( result );
    }

}
